#include <bits/stdc++.h>
using namespace std;
struct flow
{
    double d;
    double v0;
    double a;
    double v1;
};
flow car[100001];
long long detect[100001],max_d=-1;
bool flag=true,if_used_bucket[1000001];
long long T,n,m,L,V,ans1,ans2;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(long long i=0;i<T;i++)
    {
        cin>>n>>m>>L>>V;
        for(long long i=1;i<=n;i++)
        {
            cin>>car[i].d>>car[i].v0>>car[i].a;
            if(car[i].a)
                flag=false;
        }
        for(long long i=1;i<=m;i++)
        {
            cin>>detect[i];
            max_d=max(detect[i],max_d);
            if_used_bucket[detect[i]]=true;
        }

        if(flag)
        {
            for(int i=1;i<=n;i++)
            {
                if(car[i].v0>V&&car[i].d<=max_d)
                    ans1++;
            }
            cout<<ans1<<" "<<1<<endl;
            for(long long i=1;i<=n;i++)
            {
                car[i].d=0;
                car[i].v0=0;
                car[i].a=0;
            }
            for(long long i=0;i<=L;i++)
                if_used_bucket[i]=false;
            ans1=0;
            max_d=-1;
            continue;
        }
        for(long long i=1;i<=n;i++)
        {
            if(car[i].a==0&&car[i].v0>V&&car[i].d<=max_d)
                ans1++;
            if(car[i].a>0)
            {
                for(long long j=1;j<=m;j++)
                {
                    if(detect[j]<car[i].d)
                        continue;
                    car[i].v1=double(sqrt(car[i].v0*car[i].v0+2*car[i].a*(detect[j]-car[i].d)));
                    if(car[i].v1>V)
                    {
                        ans1++;
                        if_used_bucket[detect[j]]=false;
                        break;
                    }
                }
            }

            if(car[i].a<0)
            {
                if(car[i].v0<=V)
                    continue;
                for(long long j=1;j<=m;j++)
                {
                    if(detect[j]<car[i].d)
                        continue;
                    if(car[i].v0*car[i].v0+2*car[i].a*(detect[j]-car[i].d)<=0)
                        break;
                    car[i].v1=double(sqrt(car[i].v0*car[i].v0+2*car[i].a*(detect[j]-car[i].d)));
                    if(car[i].v1>V)
                    {
                        ans1++;
                        if_used_bucket[detect[j]]=false;
                        break;
                    }
                }
            }
        }


        for(long long i=0;i<=L;i++)
            ans2+=if_used_bucket[i];
        cout<<ans1<<" "<<ans2-1<<endl;


        for(long long i=1;i<=n;i++)
        {
            car[i].d=0;
            car[i].v0=0;
            car[i].a=0;
        }
        for(long long i=0;i<=L;i++)
            if_used_bucket[i]=false;
        ans1=0;
        ans2=0;
    }
    return 0;
}
